package com.cloudoer.blog.service.impl;

import com.cloudoer.blog.base.BaseService;
import com.cloudoer.blog.model.Comment;
import com.cloudoer.blog.service.CommentService;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service(value = "commentService")
public class CommentServiceImpl extends BaseService implements CommentService {
    @Override
    public Comment getById(String id) {
        return commentDao.selectByPrimaryKey(id);
    }

    @Override
    public String add(Comment comment) {
        comment.setId(UUID.randomUUID().toString().replace("-", ""));
        commentDao.insertSelective(comment);
        return comment.getId();
    }

    @Override
    public int update(Comment comment) {
        return commentDao.updateByPrimaryKeyWithBLOBs(comment);
    }

    @Override
    public int delete(String id) {
        return commentDao.deleteByPrimaryKey(id);
    }
}
